//
//  AudioPublishBottom.m
//  ShangHaiTuJI
//
//  Created by xiaoxiangtuji on 2017/11/14.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "AudioPublishBottom.h"

@implementation AudioPublishBottom

+(instancetype)initWithaddView:(UIView *)faterView AndAboveView:(UIView *)aboveView AndTitle:(NSString *)title AndPlaceholder:(NSString *)placeHolder AndShowMustToStar:(BOOL)showStar{
    AudioPublishBottom *view = [[AudioPublishBottom alloc] init];
    [faterView addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(faterView);
        make.height.mas_equalTo(scaleTopAndBottom(44));
        make.top.equalTo(aboveView.mas_bottom);
    }];
    UILabel *titleLabel = [[UILabel alloc] init];
    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:title];
    titleLabel.attributedText = attri;
    titleLabel.font = [UIFont systemFontOfSize:14];
    titleLabel.textColor = COLOR_HEX(0x121212);
    if (showStar) {
        NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@",@"*",title]];
        [view attaributestrMakeDesign:attri];
        titleLabel.attributedText = attri;
    }
    [view addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(view.mas_left).offset(scaleLeftAndRight(10));
        make.centerY.equalTo(view.mas_centerY);
        make.height.mas_equalTo(scaleTopAndBottom(30));
        make.width.mas_equalTo(scaleLeftAndRight(60));
    }];
    UIImageView *arrowImageView = [[UIImageView alloc] init];
    arrowImageView.backgroundColor = [UIColor redColor];
    [view addSubview:arrowImageView];
    [arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(view.mas_centerY); make.right.equalTo(view.mas_right).offset(scaleLeftAndRight(-10));
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(10), scaleTopAndBottom(18)));
        
    }];
    
    UILabel *placeholderLabel = [[UILabel alloc] init];
    placeholderLabel.text = placeHolder;
    placeholderLabel.font = [UIFont systemFontOfSize:14];
    placeholderLabel.textColor = COLOR_HEX(0xC0C0C0);
    [view addSubview:placeholderLabel];
    [placeholderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(titleLabel.mas_right).offset(scaleLeftAndRight(30));
        make.right.equalTo(arrowImageView.mas_left).offset(scaleLeftAndRight(60));
        make.height.mas_equalTo(scaleTopAndBottom(30));
        make.centerY.equalTo(view.mas_centerY);
    }];
    
    return view;
}
-(void)attaributestrMakeDesign:(NSMutableAttributedString *)attri{
    [attri addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
